let foo: number | string = 213;

foo = "qwe";

if (typeof foo === "string") {
  console.log(foo.length);
}

function printID(id: string | number) {
  if (typeof id === "string") {
    console.log(id.length);
  }
  console.log("id" + id);
}

printID(123);
printID("!@3");

export { }
